package com.smileymedia.view;


import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.Paint.Style;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.smileymedia.core.Constants;
import com.smileymedia.core.LayoutEngine;
/**
 * View responsible for drawing transparent panel
 * @author greg
 *
 */
public class TransparentView extends LinearLayout {

	public TransparentView(Context context, AttributeSet attributes){
		super(context, attributes);
		mAttributes = attributes;
	    //String raw=mAttributes.getAttributeValue(Constants.ANDROID_NAMESPACE, "background");
		
		mBackgroundColor=mAttributes.getAttributeIntValue(Constants.ANDROID_NAMESPACE, "background", 0x00000000);
		
		String raw=mAttributes.getAttributeValue(Constants.SMILEY_NAMESPACE, "alpha");
		int alpha=Integer.parseInt(raw);
		Log.d(TAG, "**  Raw = "+alpha);
		Log.d(TAG, "**  mBackgroundColor = "+mBackgroundColor);
		mInnerPaint = new Paint();
		///mInnerPaint.setARGB(alpha, 150, 150, 150);
		mInnerPaint.setColor(mBackgroundColor);
		
		mBorderPaint = new Paint();
		mBorderPaint.setARGB(255, 0, 0, 0);
		mBorderPaint.setAntiAlias(true);
		mBorderPaint.setStyle(Style.STROKE);
		mBorderPaint.setStrokeWidth(2);
		
	}
	
	public TransparentView(Context context) {
		super(context);
		mContext=context;		
	}


	@Override
	protected void dispatchDraw(Canvas canvas) {
	
		RectF drawRect = new RectF();
		drawRect.set(0,0, getMeasuredWidth(), getMeasuredHeight());

		canvas.drawRoundRect(drawRect, 5, 5, mInnerPaint);
		canvas.drawRoundRect(drawRect, 5, 5, mBorderPaint);		
		super.dispatchDraw(canvas);
	}


	//Private Variables
	private static final String TAG = TransparentView.class.getSimpleName();
	private Context mContext;
	private LayoutEngine mLayout;
	private AttributeSet mAttributes;
	public Paint mInnerPaint;
	
	public int mBackgroundColor;
	private Paint mBorderPaint;

}
